<Project>
  <PropertyGroup>
    <BeforePack>GenerateNupkgProps;$(BeforePack)</BeforePack>
    <PropsFilePath>$(BaseIntermediateOutputPath)$(PackageId).props</PropsFilePath>
  </PropertyGroup>

  <ItemGroup>
    <None Include="$(PropsFilePath)"
          PackagePath="build"
          Pack="true" />
  </ItemGroup>

  <Target Name="GenerateNupkgProps"
          Inputs="$(MSBuildThisFileFullPath)"
          Outputs="$(PropsFilePath)">
    <PropertyGroup>
      <PropsFileContents>
&lt;Project&gt;
  &lt;ItemGroup&gt;
    &lt;DotNetCliToolReference Include="$(PackageId)" Version="$(PackageVersion)" /&gt;
  &lt;/ItemGroup&gt;
  &lt;PropertyGroup&gt;
    &lt;SgenPackSerializer Condition="'%24(SgenPackSerializer)'==''"&gt;True&lt;/SgenPackSerializer&gt;
  &lt;/PropertyGroup&gt;
  &lt;ItemGroup Condition="'%24(SgenPackSerializer)'=='True'"&gt;
    &lt;BuildOutputInPackage Include="%24(OutputPath)%24(AssemblyName).XmlSerializers.dll" /&gt;
  &lt;/ItemGroup&gt;
&lt;/Project&gt;
      </PropsFileContents>
    </PropertyGroup>

    <WriteLinesToFile File="$(PropsFilePath)"
                      Lines="$(PropsFileContents)"
                      Overwrite="true" />
  </Target>
</Project>
